package org.litemall.netty.config;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.ApplicationArguments;
import org.springframework.boot.ApplicationRunner;
import org.springframework.stereotype.Component;

import java.util.concurrent.Executors;

/**
 * @Author Lizr
 * @Description 异步启动 netty
 * @CreateTime 2021-12-17 下午 4:04
 **/
@Component
public class ApplicationInit implements ApplicationRunner {
    @Autowired
    private NettyBootsrapRunner runner;
    @Override
    public void run(ApplicationArguments args) throws Exception {
        Executors.newSingleThreadExecutor().execute(new Runnable() {
            @Override
            public void run() {
                try {
                    runner.start();
                } catch (Exception e) {
                    e.printStackTrace();
                }
            }
        });
    }
}
